
#Title[ʏ7]
#Text[]
#Image[]
#BackGround[]
#BGM[]
#PlayLevel[Extra]
#ScriptVersion[2]
#Player[FREE]


script_enemy_main
{

	@Initialize
	{
	SetLife(4000);
	SetDamageRate(200,  100);
	SetTimer(60);
	SetInvincibility(250);
	SetEnemyMarker(true);
	SetGraphicRect(64,1,127,64);
	LoadGraphic("script\img\ExRumia.png");
	}
	//   ʒu܂ňړ
	SetMovePosition02(GetCenterX, GetCenterY-120, 60);

	AtackTaskA;
	MoveTask;
	@MainLoop
	{
		yield;

		SetGraphicRect(0,1,63,64);
		if(GetSpeedX<0){
			SetGraphicRect(128,1,191,64);
		}
		if(GetSpeedX>0){
			SetGraphicRect(192,1,255,64);
		}

		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 24);
	}
	
	@DrawLoop
	{
		SetColor(255,255,255);
		SetAlpha(255);
		SetTexture("script\img\ExRumia.png");//摜͔q
		DrawGraphic(GetX,GetY);
	}
		
	@Finalize
	{
		DeleteGraphic("script\img\ExRumia.png");
	}
	//XyJ[h̔wi
	//Ă悢
/*	@BackGround
	{
	}
*/
	task AtackTaskA{
		wait(120);
		let colorcnt=0;
		let grf=[RED01,GREEN01,BLUE01];
		while(true){
			let dir=rand(0,360);
			let rot=0;
			let nway=8;
			let ammo=16;
			loop(nway){
				loop(ammo){
					CreateShot01(GetX,GetY,2,dir+rot,grf[colorcnt%3],20);
					rot+=2;
				}
				dir+=360/nway;
				rot=0;
				colorcnt++;
			}
			wait(30);

		}
	}

	task MoveTask{		//@Ɉړp^[
		wait(240);
		while(true){
			let ptn=0;
			if(GetX<GetCenterX-80){ptn=1;}
			if(GetX>GetCenterX+80){ptn=2;}
			if(ptn==0){
				if(GetX<GetPlayerX){ptn=1;}
				else{ptn=2;}
			}
			if(ptn==1){
				SetMovePosition02(rand(GetX+40,GetX+60), rand(GetClipMinY+120,GetCenterY-120), 60);
			}
			if(ptn==2){
				SetMovePosition02(rand(GetX-40,GetX-60), rand(GetClipMinY+120,GetCenterY-120), 60);
			}
			wait(150);
		}
	}

	function wait(n){
		loop(n){yield;}
	}

}

